package com.jsb.laundry.service.impl;

import com.jsb.laundry.dao.OrderInfoDao;
import com.jsb.laundry.model.dto.ViewOrderDetailsVoRequest;
import com.jsb.laundry.model.entity.*;
import com.jsb.laundry.model.vo.DeliveryOrderInformationVo;
import com.jsb.laundry.model.vo.OrderDetailsVo;
import com.jsb.laundry.model.vo.OrderListVo;
import com.jsb.laundry.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderInfoServiceImpl implements OrderInfoService {
    @Autowired
    private OrderInfoDao orderInfoDao;

    /**
     * 骑手抢单列表
     *
     * @return
     */
    @Override
    public List<OrderListVo> findByUserInfoList() {
        return orderInfoDao.findByUserInfoList();
    }

    /**
     * 查询订单方向
     *
     * @param orderId
     * @return
     */
    @Override
    public int findByOrderDirection(String orderId) {
        return orderInfoDao.findByOrderDirection(orderId);
    }

    /**
     * 送货订单信息
     *
     * @param orderId
     * @return
     */
    @Override
    public DeliveryOrderInformationVo findByOrderInfo(String orderId) {
        return orderInfoDao.findByOrderInfo(orderId);
    }

    /**
     * 更改订单状态为已接单
     *
     * @param orderId
     * @return
     */
    @Override
    public int updateOrderStatus(String orderId) {
        return orderInfoDao.updateOrderStatus(orderId);
    }

    /**
     * 查询实际订单金额
     *
     * @param orderId
     * @return
     */
    @Override
    public int findByPaidPrice(String orderId) {
        return orderInfoDao.findByPaidPrice(orderId);
    }

    /**
     * 查询骑手抢单后的订单信息
     *
     * @param riderId
     * @param orderStatus
     * @return
     */
    @Override
    public List<OrderListVo> afterTheRiderSnatchedTheOrderInfo(String riderId, String orderStatus,String orderDirection) {
        return orderInfoDao.afterTheRiderSnatchedTheOrderInfo(riderId,orderStatus,orderDirection);
    }

    /**
     * 查询瑕疵
     *
     * @param type
     * @return
     */
    @Override
    public List<Flaw> findByFlaw(String keyword,String type) {
        return orderInfoDao.findByFlaw(keyword,type);
    }

    /**
     * 查询瑕疵分类
     *
     * @return
     */
    @Override
    public List<Flaw> findByFlawType() {
        return orderInfoDao.findByFlawType();
    }

    /**
     * 查询配饰
     *
     * @return
     */
    @Override
    public List<Accessories> findByAccessories(String keyword) {
        return orderInfoDao.findByAccessories(keyword);
    }

    /**
     * 查询品牌
     *
     * @return
     */
    @Override
    public List<Brand> findByBrand(String keyword) {
        return orderInfoDao.findByBrand(keyword);
    }

    /**
     * 查询效果
     *
     * @return
     */
    @Override
    public List<Effect> findByEffect(String keyword) {
        return orderInfoDao.findByEffect(keyword);
    }

    /**
     * 查询颜色
     *
     * @return
     */
    @Override
    public List<Colour> findByColour(String keyword) {
        return orderInfoDao.findByColour(keyword);
    }

    /**
     * 查询用户是否在线
     *
     * @param userId
     * @return
     */
    @Override
    public String findByUserLogin(String userId) {
        return orderInfoDao.findByUserLogin(userId);
    }

    /**
     * 取货
     *
     * @param orderStatus
     * @param orderId
     * @return
     */
    @Override
    public int pickUp(String orderStatus, String orderId) {
        return orderInfoDao.pickUp(orderStatus,orderId);
    }

    @Override
    public int updfactoryStatus(String orderId) {
        return orderInfoDao.updfactoryStatus(orderId);
    }

    @Override
    public int updorderStatus(String orderStatus, String orderId) {
        return orderInfoDao.updorderStatus(orderStatus,orderId);
    }


    /**
     * 根据订单号查询子订单列表
     *
     * @param orderId
     * @return
     */
    @Override
    public List<OrderDetailsVo> findBySybOrderIdList(String orderId) {
        return orderInfoDao.findBySybOrderIdList(orderId);
    }


    /**
     * 更新子订单详情
     *
     * @param viewOrderDetailsVoRequest
     * @return
     */
    @Override
    public Integer updateSubDetails(List<ViewOrderDetailsVoRequest>  viewOrderDetailsVoRequest) {
        return orderInfoDao.updateSubDetails(viewOrderDetailsVoRequest);
    }

    /**
     * 查询订单是否为当前骑手抢的
     * @param orderId
     * @param userId
     * @return
     */
    @Override
    public String findByOrderInfoTc(String orderId, String userId) {
        return orderInfoDao.findByOrderInfoTc(orderId,userId);
    }

    /**
     * 查看已交接
     *
     * @param riderId
     * @return
     */
    @Override
    public List<OrderListVo> viewHandover(String riderId) {
        return orderInfoDao.viewHandover(riderId);
    }

    /**
     * 根据用户订单号查询手机号
     *
     * @param orderId
     * @return
     */
    @Override
    public String findByUserPhone(String orderId) {
        return orderInfoDao.findByUserPhone(orderId);
    }

    /**
     * 完成订单信息
     *
     * @param riderId
     * @return
     */
    @Override
    public List<OrderListVo> okOrderInfo(String riderId) {
        return orderInfoDao.okOrderInfo(riderId);
    }

    /**
     * 根据用户订单号查询手机号
     *
     * @param orderId
     * @return
     */
    @Override
    public String findByUserPhoneBack(String orderId) {
        return orderInfoDao.findByUserPhoneBack(orderId);
    }

    /**
     * 查询订单状态
     *
     * @param orderId
     * @return
     */
    @Override
    public String findByOrderStatus(String orderId) {
        return orderInfoDao.findByOrderStatus(orderId);
    }

    /**
     * 根据订单号查询商品数量
     *
     * @param orderId
     * @return
     */
    @Override
    public int findByOrderNum(String orderId) {
        return orderInfoDao.findByOrderNum(orderId);
    }

    /**
     * 重复抢单
     *
     * @param orderId
     * @param direction
     * @return
     */
    @Override
    public int repeat(String orderId, String direction) {
        return orderInfoDao.repeat(orderId,direction);
    }

    /**
     * 查询抢单用户id
     *
     * @param orderId
     * @return
     */
    @Override
    public String findByRiderInfoId(String orderId) {
        return orderInfoDao.findByRiderInfoId(orderId);
    }

    @Override
    public String findByRiderInfoId1(String orderId) {
        return orderInfoDao.findByRiderInfoId1(orderId);
    }

    @Override
    public int updateDeliveryStatus(String orderId, String deliveryStatus) {
        return orderInfoDao.updateDeliveryStatus(orderId,deliveryStatus);
    }
}
